package com.yaoxun.console.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import com.yaoxun.console.constant.CacheConstant;
import com.yaoxun.console.context.SubjectContextHolder;
import com.yaoxun.console.xo.dto.LoginSession;

@Service
public class LogoutService {

	@Autowired
	private StringRedisTemplate streRedisTemplate;
	
	
	public void logout() {
		
		LoginSession session = SubjectContextHolder.getContext();
		
		String loginSessionKey = String.format(CacheConstant.LOGIN_SESSION, session.getSid());
		
		streRedisTemplate.delete(loginSessionKey);
		
	}
	
}
